import { createApp } from 'vue';

const app = createApp({});
const eventBus = app.config.globalProperties.$eventBus = app;

// 创建一个新的Vue实例
const emitter = createApp({});
// 添加emit方法
emitter.config.globalProperties.$emit = function(event, ...args) {
  this._instanceProxy.$emit(event, ...args);
};

// 添加on方法
emitter.config.globalProperties.$on = function(event, callback) {
  this._instanceProxy.$on(event, callback);
};

// 将emitter对象作为eventBus的属性
eventBus.emitter = emitter;

export default eventBus;
